﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LynxWebLog
{
    public static class CookieFacade
    {
        public static string CurrentBlog
        {
            get { 
                if (HttpContext.Current.Request.Cookies["_currentBlog"] != null) {
                    HttpContext.Current.Request.Cookies["_currentBlog"].Expires = DateTime.Now.AddMonths(1);
                    return HttpContext.Current.Request.Cookies["_currentBlog"].Value;
                } else {
                    return string.Empty;
                }
            }
            set {
                if (HttpContext.Current.Request.Cookies["_currentBlog"] != null) {
                    HttpContext.Current.Response.Cookies["_currentBlog"].Expires = DateTime.Now.AddMonths(1);
                    HttpContext.Current.Response.Cookies["_currentBlog"].Value = value;
                } else {
                    HttpCookie cookie = new HttpCookie("_currentBlog");
                    cookie.Expires = DateTime.Now.AddMonths(1);
                    cookie.Value = value;
                    HttpContext.Current.Response.Cookies.Add(cookie);
                }
            }
        }
    }
}